home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / cmln1085.arc / GSXINPUT.INC < prev    next >
Text File  |  1986-02-27  |  7KB  |  151 lines

  1. { --- input functions.    Include file GSXINPUT.INC  --- }
  2. {*************************************************************************}
  3. procedure setinputmode( input,     {in: input device requested:
  4.                                         1 = locator       2 = valuator
  5.                                         3 = choice        4 = string }
  6.  
  7.                         mode : integer; {in : requested mode:
  8.                                         1 = request   2 = sample   }
  9.             var realizedmode : integer  {out: mode realized by the device}
  10.                              );         {     0= device not supported}
  11. {*************************************************************************}
  12.   var    contrl : array[1..5] of integer;
  13.          intin  : array[1..2] of integer;
  14.          ptsin, intout, ptsout : integer;
  15.  
  16.   begin   contrl[1] := 33;
  17.           contrl[2] :=  0;
  18.           contrl[4] :=  2;
  19.           intin[1]  := input;
  20.           intin[2]  := mode;
  21.           setpblock( addr(contrl), addr(intin ),
  22.                      addr(ptsin ), addr(intout),
  23.                      addr(ptsout));
  24.           callgdos( addr(pb));
  25.           realizedmode :=intout   {0 indicates device not supported }
  26.    end;
  27.  
  28. {**********************************************************************}
  29. function inputlocator( device,          {in: device number for input}
  30.                          mode,          {in: 1=request    2=sample}
  31.                         x, y : integer; {in: initial coords of locator
  32.                                              (request mode only,
  33.                                               ignored if sample mode)}
  34.            var finalx, finaly: integer; {out: final coords of locator}
  35.            var    terminator : char     {out: terminator character }
  36.                             ): integer; {out: 0 = not successful
  37.                                               >0= successful }
  38. {**********************************************************************}
  39.   var   contrl : array[1..5] of integer;
  40.         ptsin, ptsout  : array[1..2] of integer;
  41.         intin, intout : integer;
  42.  
  43.   begin    contrl[1] := 28;
  44.            if mode = 2 then contrl[2] :=  0  else contrl[2] := 1;
  45.            contrl[4] :=  1;
  46.            intin     := device;
  47.            if contrl[2] = 1 then begin
  48.               ptsin[1]  :=  x;
  49.               ptsin[2]  :=  y
  50.            end {if};
  51.            setpblock( addr(contrl), addr(intin ),
  52.                       addr(ptsin ), addr(intout),
  53.                       addr(ptsout));
  54.            callgdos( addr(pb));
  55.            inputlocator := contrl[5];
  56.            finalx := ptsout[1];
  57.            finaly := ptsout[2];
  58.            terminator := chr(intout)
  59.   end;
  60.  
  61. {***********************************************************************}
  62. function inputvaluator( device,          {in: device no. for input}
  63.                           mode,          {in: 1=request     2=sample}
  64.                       invalue : integer; {in: initial NDC value
  65.                                               request mode only, ignored
  66.                                               in sample mode}
  67.                  var outvalue : integer  {out: NDC output value returned}
  68.                              ): integer; {out: 0=successful
  69.                                               >1=unsuccessful}
  70. {***********************************************************************}
  71.   var   contrl : array[1..5] of integer;
  72.         intin  : array[1..2] of integer;
  73.         ptsin, intout, ptsout : integer;
  74.  
  75.   begin     contrl[1] := 29;
  76.             contrl[2] :=  0;
  77.             if mode = 2 then contrl[4]:=1 else contrl[4] :=  2;
  78.             intin[1]  := device;
  79.             if contrl[4] = 2 then intin[2]  := invalue;
  80.             setpblock( addr(contrl), addr(intin ),
  81.                        addr(ptsin ), addr(intout),
  82.                        addr(ptsout));
  83.             callgdos( addr(pb));
  84.             inputvaluator := contrl[5];
  85.             outvalue := intout
  86.   end;
  87.  
  88. {**************************************************************************}
  89. function inputchoice( device,           {in: 1=default, 2=function key,
  90.                                              >2 = workstation dependent}
  91.                         mode,           {in: 1=request, 2=sample}
  92.                    inchoice : integer;  {in: initial choice requested,
  93.                                              request mode only, ignored if
  94.                                              sample mode}
  95.                  var choice : integer   {out: choice device number if
  96.                                              successful}
  97.                            ): integer;  {out: 0 = request unsuccessful
  98.                                              >1 = request successful}
  99. {**************************************************************************}
  100.   var   contrl : array[1..5] of integer;
  101.         intin  : array[1..2] of integer;
  102.         intout, ptsin, ptsout : integer;
  103.  
  104.   begin     contrl[1] := 30;
  105.             contrl[2] :=  0;
  106.             if mode = 2 then contrl[4] :=  1  else contrl[4]:= 2;
  107.             intin[1]  := device;
  108.             if contrl[4] = 2 then intin[2]  := inchoice;
  109.             setpblock( addr(contrl), addr(intin ),
  110.                        addr(ptsin ), addr(intout),
  111.                        addr(ptsout));
  112.             callgdos( addr(pb));
  113.             choice := contrl[5];
  114.             inputchoice := intout
  115.   end;
  116.  
  117. {************************************************************************}
  118. function inputstring( device,            {in: 1=default device (keybd)
  119.                                              >1=workstation dependent}
  120.                        echo : integer;   {in: 1=echo chars on screen
  121.                                               0=inhibit screen echo}
  122.                     var len : integer    {out: actual length of requested
  123.                                               string}
  124.                            ): string255; {out: returned string <= 255 chars}
  125. {************************************************************************}
  126.       { operates in either sample or request mode}
  127.   var    contrl : array[1..5] of integer;
  128.          intin  : array[1..3] of integer;
  129.          intout : array[1..255] of integer;
  130.          ptsin, ptsout : integer;
  131.          i      : byte;
  132.              st : string255;
  133.  
  134.   begin     contrl[1] := 31;
  135.             contrl[2] :=  0;
  136.             contrl[4] :=  3;
  137.             intin[1]  := device;
  138.             intin[2]  := 255;
  139.             intin[3]  := echo;
  140.             setpblock( addr(contrl), addr(intin ),
  141.                        addr(ptsin ), addr(intout),
  142.                        addr(ptsout));
  143.             callgdos( addr(pb));
  144.             len := contrl[5];
  145.             st := '';
  146.             if (len > 0) and (len <= 255) then for i := 1 to len do
  147.                  st := st + chr(intout[i]);
  148.             inputstring := st
  149.   end;
  150.  
  151.